<?php
// Comparison function
function cmp($a, $b) {
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? -1 : 1;
}

// Array to be sorted
$array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);
print_r($array);

// Sort and print the resulting array
uasort($array, 'cmp');
print_r($array);
function search_group_id(goods_id,style_id,goods_number,goods_price)
	{
		var is_exited = "";
		function inner_ajax(){		
			$.ajax({
					async : false,
					dataType : "json",
					data: "goods_id=" + goods_id+
						  "&style_id=" + style_id+
						  "&goods_number=" + goods_number+
						  "&goods_price=" + goods_price,
					url : WEB_ROOT + "admin/ajax.php?act=search_group_id",
					type : 'POST',
					success : function(response) {	
						console.log(response);
						//check_is_exited(response);
						is_exited=check_is_exited(response);
						// if(is_exited == true){
						// 	alert("套餐已存在");
						// }
						//alert(is_exited);
						//return is_exited;
					},
					error: function() { 
						alert('error'); 
					}
			});
			return is_exited;
		}
		return inner_ajax;
	}

	function check_is_exited(goods_list)
	{
		if(goods_list==""){
			console.log("空值");
			return false;
		}
		else{
			console.log("进入分支");
			var good_kinds_num = $("#goods_list tr").length-1;
			var goods_list_count = goods_list.length;
			console.log(good_kinds_num);
			console.log(goods_list_count);
			if(good_kinds_num!=goods_list_count){
				console.log("返回");
				return false;
			}
			else{
				console.log("两个条数相等进入判断");
				var Array2=new Array(); //后台来的数据放入数组
				for(var i=0;i<goods_list_count;i++){
					Array2[i]=new Array(); 
					// for(var j=0;j<4;j++){
					// 	Array2[i][j]=1;
					// 	}
				}
				//console.log(goods_list[0]['price']);
				for (var i = 0; i< goods_list_count; i++) {	
						console.log("测试2");			
						Array2[i][0]=goods_list[i]['goods_id'];
						Array2[i][1]=goods_list[i]['style_id'];
						Array2[i][2]=goods_list[i]['goods_number'];
					};
					//alert(Array2);
				console.log(Array2);
				console.log($("#goods_list tr").length);

				var Array1=new Array();//前台的数据放入数组
				for(var i=0;i< good_kinds_num;i++){
					Array1[i]=new Array(); 
				}
				for (var i = 1; i < $("#goods_list tr").length; i++) {
					console.log("测试");
					var goods_id = $("#goods_list tr").eq(i).children().attr("goods_id");
					var style_id = $("#goods_list tr").eq(i).children().attr("style_id");
					var goods_number = $("#goods_list tr").eq(i).find("td").eq(3).text();
					//console.log(goods_id);
					//var Array1 = {};
					Array1[i-1][0] = goods_id;
					Array1[i-1][1] = style_id;
					Array1[i-1][2] = goods_number;					
				}
				console.log(Array1);
				
			}		
		}
	}
?>